SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE FUNCTION [dbo].[fnObtenerUltNumeroRegistroTitulo]  ()
RETURNS  INT AS  
BEGIN 

	DECLARE @NroRegistro INT

	-- Se obtiene el valor de la tabla tb_TitulosDelAgente
	SELECT  TOP 1 @NroRegistro = max(NumeroRegistro)+1
	FROM tb_TitulosDelAgente P

	IF @NroRegistro IS NULL
		SELECT   @NroRegistro = 1


	RETURN(@NroRegistro)

END
GO
